﻿using Hidistro.Core;
using Hidistro.Entities.Sales;
using Hidistro.Membership.Context;
using Hidistro.SaleSystem.Vshop;
using Hidistro.SqlDal.Sales;
using Hidistro.UI.Common.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.UI.WebControls;

namespace Hidistro.UI.SaleSystem.CodeBehind
{
    public class VsubmmitOrderNew : HtmlTemplatedWebControl
    {
        private IButton btnCreateOrder;

         private TextBox txtShipTo;
        private TextBox txtCellPhone;
        private TextBox txtAddress;
        private TextBox txtMessage;
        private RegionSelector dropRegions;

     
        protected override void AttachChildControls()
        {
            this.btnCreateOrder = ButtonManager.Create(this.FindControl("btnCreateOrder"));
            this.btnCreateOrder.Click += new EventHandler(this.btnCreateOrder_Click);
          
        }


        /// <summary>
        /// 提交订单
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public void btnCreateOrder_Click(object sender, EventArgs e)
        {
            
                                ShippingAddressInfo shippingAddress = new ShippingAddressInfo
                                {
                                    UserId = HiContext.Current.User.UserId,
                                    ShipTo = Globals.HtmlEncode(this.txtShipTo.Text),
                                    RegionId = this.dropRegions.GetSelectedRegionId().Value,
                                    Address = Globals.HtmlEncode(this.txtAddress.Text),
                                    CellPhone = this.txtCellPhone.Text,
                          
                                };
                                ShippingAddressDao shipp = new ShippingAddressDao();
                                shipp.AddShippingAddress(shippingAddress);
        
        }

  



        protected override void OnInit(EventArgs e)
        {
            if (this.SkinName == null)
            {
                this.SkinName = "skin-vSubmmitorderNew.html";
            }
            base.OnInit(e);
        }

    }
    

}
